﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Linq.Expressions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace UnitTest.Mock
{
    internal class ContaObservable : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        private int _money;
        internal int Money
        {
            get { return _money; }
            set
            {
                _money = value;
                this.NotifyPropertyChanged("Money");
            }
        }

        internal String ResultOfPrint { get; set; }

        internal ContaObservable(int money)
        {
            this.Money = money;
        }

        internal void Withdraw(int howMuch)
        {
            Money -= howMuch;
        }

        internal void Print()
        {
            ResultOfPrint = Money.ToString();
        }

        private void NotifyPropertyChanged(String propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
